<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
		<table class="table table-hover table-bordered table-list">
			<thead>
			<tr>
				<th width="50">ID</th>
				<th>用户名</th>
				<th width="65">手机号</th>
				<th>邮箱</th>
				<th>内容</th>
				<th width="200">登记时间</th>
				<th width="130">状态</th>
				<th width="130">操作</th>
			</tr>
			</thead>
			<foreach name="list" item="vo">
				<tr>
					<td><b>{$vo.id}</b></td>
					<td width="90">
						{$vo.name}
					</td>
					<td>{$vo.phone}</td>
					<td>
						{$vo.email}
					</td>
					<td>
						{$vo.content}
					</td>
					<td>
						{$vo.create_time|date="Y-m-d H:i:s",###}
					</td>
					<td>
						<if condition="$vo.status eq 1">
							<span style="color:green;">已回访</span>
							<else/>
							<a href="{:url('Comment/updateStatus',array('id'=>$vo['id']))}" class="js-ajax-status"><span style="color:red;">未回访</span></a>
						</if>
					</td>
					<td>
						<a href="{:url('Comment/delete',array('id'=>$vo['id']))}" class="js-ajax-delete">{:lang('DELETE')}</a>
					</td>
				</tr>
			</foreach>
			<tfoot>
			<tr>
				<th width="50">ID</th>
				<th>用户名</th>
				<th width="65">手机号</th>
				<th>邮箱</th>
				<th>内容</th>
				<th width="200">登记时间</th>
				<th width="130">状态</th>
			</tr>
			</tfoot>
		</table>
		<ul class="pagination">{$page|default=''}</ul>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>

    function reloadPage(win) {
        win.location.reload();
    }

    //所有的删除操作，删除数据后刷新页面
    if ($('a.js-ajax-status').length) {
        Wind.css('artDialog');
        Wind.use('artDialog', 'noty', function () {
            $('.js-ajax-status').on('click', function (e) {
                e.preventDefault();
                var $_this  = this,
                    $this   = $($_this),
                    href    = $this.data('href'),
                    refresh = $this.data('refresh'),
                    msg     = $this.data('msg');
                href        = href ? href : $this.attr('href');

                art.dialog({
                    title: false,
                    icon: 'question',
                    content: msg ? msg : '确定已回访了吗？',
                    follow: $_this,
                    close: function () {
                        $_this.focus(); //关闭时让触发弹窗的元素获取焦点
                        return true;
                    },
                    okVal: "确定",
                    ok: function () {
                        $.getJSON(href).done(function (data) {
                            if (data.code == '1') {
                                noty({
                                    text: data.msg,
                                    type: 'success',
                                    layout: 'topCenter',
                                    modal: true,
                                    // animation: {
                                    //     open: 'animated bounceInDown', // Animate.css class names
                                    //     close: 'animated bounceOutUp', // Animate.css class names
                                    // },
                                    timeout: 800,
                                    callback: {
                                        afterClose: function () {
                                            if (refresh == undefined || refresh) {
                                                if (data.url) {
                                                    //返回带跳转地址
                                                    window.location.href = data.url;
                                                } else {
                                                    //刷新当前页
                                                    reloadPage(window);
                                                }
                                            }
                                        }
                                    }
                                }).show();

                            } else if (data.code == '0') {
                                //art.dialog.alert(data.info);
                                //alert(data.info);//暂时处理方案
                                art.dialog({
                                    content: data.msg,
                                    icon: 'warning',
                                    ok: function () {
                                        this.title(data.msg);
                                        return true;
                                    }
                                });
                            }
                        });
                    },
                    cancelVal: '关闭',
                    cancel: true
                });
            });

        });
    }
</script>
</body>
</html>